var uid = location.search.substr(location.search.indexOf('=') + 1)
var newPwd1 = $("#newPwd1").val()
var newPwd2 = $("#newPwd2").val()

$(function () {
  getUserById()
})

//提交密码
function changePwd() {
  if ($("#newPwd1").val() == $("#newPwd2").val()) {
    //alert($("#newPwd1").val())
    newPwd1 = $('#newPwd1').val()
    updataPwd()
    app.plist = getUserPagin(pageIndex, pageSize)
    layui.use('layer', function () {
      var layer = layui.layer
      layer.msg('修改成功！')
    })
  }
}

//提交修改密码
function updataPwd() {
  $.ajax({
    url: 'http://47.102.45.219:8080/Appoint/UserServlet/updataPwd',
    // xhrFields: {
    //     withCredentials: true
    // },
    async: false,
    dataType: 'json',
    data: {
      id: uid,
      pwd: newPwd1
    },
    success: function (data) {
      xadmin.close();
      xadmin.father_reload();
      if (data.statu) {
        layui.use('layer', function () {
          var layer = layui.layer
          layer.msg('修改成功！')
        })
      }
    }
  })
}


//ajax获取密码
function getUserById() {
  // alert(uid)
  $.ajax({
    url: 'http://47.102.45.219:8080/Appoint/UserServlet/getUserById',
    data: {
      "id": uid
    },
    async: false,
    success: function (data) {
      list = data.data[0].pwd
      //alert(list)
    },
    dataType: 'json',
    type: 'post'
  })

  return list
}